home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MacSplitPaneDivider.java < prev    next >
Text File  |  1998-06-30  |  3KB  |  116 lines

  1. /*
  2.  * @(#)MacSplitPaneDivider.java    1.6 98/02/02
  3.  *
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  *
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.mac;
  22.  
  23. import java.awt.*;
  24. import com.sun.java.swing.JSplitPane;
  25. import com.sun.java.swing.UIManager;
  26. import com.sun.java.swing.plaf.basic.BasicSplitPaneUI;
  27. import com.sun.java.swing.plaf.basic.BasicSplitPaneDivider;
  28.  
  29. /**
  30.  * Divider used for Mac split pane.
  31.  * <p>
  32.  * Warning: serialized objects of this class will not be compatible with
  33.  * future swing releases.  The current serialization support is appropriate
  34.  * for short term storage or RMI between Swing1.0 applications.  It will
  35.  * not be possible to load serialized Swing1.0 objects with future releases
  36.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  37.  * baseline for the serialized form of Swing objects.
  38.  *
  39.  * @version @(#)MacSplitPaneDivider.java    1.0 11/24/97
  40.  * @author Symantec
  41.  * @author David Bustin
  42.  */
  43. public class MacSplitPaneDivider extends BasicSplitPaneDivider
  44. {
  45.     public static final int minimumSize = 6;
  46.     public static final int defaultDividerSize = 6;
  47.  
  48.     protected Color highlightColor;
  49.     protected Color shadowColor;
  50.  
  51.     /**
  52.      * Creates a new Mac SplitPaneDivider
  53.      */
  54.     public MacSplitPaneDivider(BasicSplitPaneUI ui) {
  55.         super(ui);
  56.         highlightColor = UIManager.getColor("SplitPane.highlight");
  57.         shadowColor = UIManager.getColor("SplitPane.shadow");
  58.         setDividerSize(defaultDividerSize);
  59.     }
  60.  
  61.     /**
  62.      * overrides to hardcode the size of the divider
  63.      */
  64.     public void setDividerSize(int newSize) {
  65.         if (newSize < minimumSize) {
  66.             setDividerSize(minimumSize);
  67.         } else {
  68.             super.setDividerSize(newSize);
  69.         }                  
  70.     }
  71.  
  72.     /**
  73.       * Paints the divider.
  74.       */
  75.     public void paint(Graphics g) {
  76.     Color               bgColor = getBackground();
  77.     Dimension           size = getSize();
  78.  
  79.     // fill
  80.     g.setColor(getBackground());
  81.     g.fillRect(0, 0, size.width-1, size.height-1);
  82.     
  83.     if (getBasicSplitPaneUI().getOrientation() == JSplitPane.HORIZONTAL_SPLIT) 
  84.         {
  85.         g.setColor(Color.black);
  86.         g.drawLine(0, 0, 0, size.height-1);
  87.  
  88.         g.setColor(highlightColor);
  89.         g.drawLine(1, 0, 1, size.height-1);
  90.  
  91.         g.setColor(shadowColor);
  92.         g.drawLine(size.width-1, 0, size.width-1, size.height-1);
  93.         } 
  94.     else 
  95.         {
  96.         g.setColor(Color.black);
  97.         g.drawLine(0, 0, size.width-1, 0);
  98.  
  99.         g.setColor(highlightColor);
  100.         g.drawLine(0, 1, size.width-1, 1);
  101.  
  102.         g.setColor(shadowColor);
  103.         g.drawLine(0, size.height-1, size.width-1, size.height-1);
  104.         }
  105.     super.paint(g);
  106.     }
  107.  
  108.     /**
  109.       * The minimums size is the same as the preferredSize
  110.       */
  111.     public Dimension getMinimumSize() {
  112.     return getPreferredSize();
  113.     }
  114.  
  115. }
  116.